var webpack = require('webpack');
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var OpenBrowserPlugin = require('open-browser-webpack-plugin');
var path = require("path");

console.log(path.join(__dirname, 'build'));

module.exports = {
  entry: {
  	bundle_thunk: './src/index_thunk.jsx',
  	bundle_promise: './src/index_promise.jsx',
  },
  output: {
  	path: path.join(__dirname, 'build'),
  	publicPath: "build/",
    filename: '[name].js'
  },
  module: {
    loaders:[
      { test: /\.jsx$/, exclude: /node_modules/, loader: 'jsx-loader!babel-loader' },
      { test: /\.js$/, exclude:/node_modules/, loader: 'babel-loader'},
    ]
  },
  resolve:{
    extensions:['.js','.jsx','.json']
  },
  devServer: {
	proxy: {
	  '/data_api/*': {
	  	target: 'http://localhost:9090',
	    secure: false,
	    pathRewrite: {'^/data_api' : ''}
	  }
	}
  },

  plugins: [
	new CommonsChunkPlugin({
		name:"init",
		filename:"init.js"//忽略则以name为输出文件的名字，否则以此为输出文件名字
	}),
    // new OpenBrowserPlugin({ url: 'http://localhost:8080' }) // 用浏览器打开网页
  ]
};
